using System;

namespace Laba3
{
    public class Trapec
    {
        public static int Meu = 3;

        public static double J1(double a, double b){
            return ((b-a)/2)*(Function.FunctionValue(a) + Function.FunctionValue(b));
        }
         
        public static double Jn(double a, double b, int n){
            if (n == 1)
                return J1(a, b);
            var result = 0.5 * Jn(a, b, n / 2);
            for (int i = 0; i <= n/2; i++)
            {
                result+=Function.FunctionValue(a + ((2*i + 1)/n)*(b-a));
            }
            return result *= (b - a) / 2;
        }
    }
}

